﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using FDFtpSync.Core;
using Newtonsoft.Json;

namespace FDFtpSync.Client
{
    /*
     * CreatedOn: 2018-05-23
     * CreatedBy: Jackie Lee(天宇遊龍)
     */
    /// <summary>
    /// Json序列
    /// </summary>
    public class JsonSerializer : ISerializer
    {
        public string ToJson(object obj)
        {
            return JsonConvert.SerializeObject(obj);
        }

        public T FromJson<T>(string str)
        {
            if (string.IsNullOrEmpty(str))
                return default(T);
            return JsonConvert.DeserializeObject<T>(str);
        }
    }
}
